#post /watchings appid=xxx, time=xxx

module API::V3
  class ClientLogs < Grape::API
    resource :client_logs do
      params do
        requires :client_id, type: Integer
        requires :client_type, type: String
        optional :log_type, type: String
        requires :log_file
      end
      post do
        client_log_param_key = ['client_id', 'client_type', 'log_type', 'log_file']
        client_log_param = {remote_ip: env['REMOTE_ADDR']}.merge(params.select { |k, v| client_log_param_key.include? k })
        result = !!(ClientLog.create client_log_param)
        present result: result
      end
    end
  end
end